package ru.amse.tsyganov.jumleditor.main;

import ru.amse.tsyganov.jumleditor.editor.Editor;
import ru.amse.tsyganov.jumleditor.model.ActionState;
import ru.amse.tsyganov.jumleditor.model.ActivityGraph;
import ru.amse.tsyganov.jumleditor.model.Partition;
import ru.amse.tsyganov.jumleditor.model.Transition;
import ru.amse.tsyganov.jumleditor.view.ActionStateView;
import ru.amse.tsyganov.jumleditor.view.ActivityGraphView;
import ru.amse.tsyganov.jumleditor.view.StateView;
import ru.amse.tsyganov.jumleditor.view.TransitionView;

public class Main {

	public static void main(String[] args) {
		ActivityGraphView<ActivityGraph> graph = createStatesModel();
		new Editor(graph);
	}

	/**
	 * @return
	 */
	private static ActivityGraphView<ActivityGraph> createStatesModel() {
		
		ActionState s1 = new ActionState();
		StateView<ActionState> v1 = new ActionStateView<ActionState>(s1);
		
		ActionState s2 = new ActionState();
		StateView<ActionState> v2 = new ActionStateView<ActionState>(s2);
		
		ActionState s3 = new ActionState();
		StateView<ActionState> v3 = new ActionStateView<ActionState>(s3);
		
		Transition t1 = new Transition(
				s1.getStateVertex(), s2.getStateVertex());
		
		Transition t2 = new Transition(
				s2.getStateVertex(), s3.getStateVertex());
		
		new TransitionView<Transition>(t1,
				v1.getStateVertex(), v2.getStateVertex());
		
		new TransitionView<Transition>(t2,
				v2.getStateVertex(), v3.getStateVertex());
		
		ActivityGraph modelGraph = new ActivityGraph();
		
		modelGraph.getPartitions().add(new Partition());
		
		modelGraph.getPartitions().get(0).getContents().add(s1);
		modelGraph.getPartitions().get(0).getContents().add(s2);
		modelGraph.getPartitions().get(0).getContents().add(s3);
		
		v1.setX(10);
		v1.setY(100);
		
		v2.setX(200);
		v2.setY(10);
		
		v3.setX(310);
		v3.setY(200);
		
		ActivityGraphView<ActivityGraph> viewGraph = 
			new ActivityGraphView<ActivityGraph>(modelGraph);
		
		viewGraph.getPartitions().get(0).getContents().add(v1);
		viewGraph.getPartitions().get(0).getContents().add(v2);
		viewGraph.getPartitions().get(0).getContents().add(v3);
		
		return viewGraph;
	}
}
